package ru.linnenson.darshana.infrastructure.persistence.repositories;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import ru.linnenson.darshana.infrastructure.persistence.models.MathTaskStore;
import ru.linnenson.darshana.infrastructure.persistence.models.QMathTaskStore;
import java.util.List;

@Repository
public interface MathTaskPersistenceRepository extends CrudRepository<MathTaskStore, Integer>,
    QuerydslPredicateExecutor<MathTaskStore>, QuerydslBinderCustomizer<QMathTaskStore> {

  @Override
  default void customize(QuerydslBindings querydslBindings, QMathTaskStore mathTaskStore) {

  }

  @Query(
      nativeQuery = true,
      value = "SELECT DISTINCT unnest(tags) FROM math_task"
  )
  List<String> findAllTags();
}
